package com.my.test.thread.conditition;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class TestConditition {

    static Lock lock = new ReentrantLock();

    static Condition c = lock.newCondition();


    public static void main(String[] args) {
        await();
        notifys();
    }

    public static void await(){
        new Thread(()->{
            lock.lock();
            try {
                c.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
    }

    public static void notifys(){
        new Thread(()->{
            lock.lock();
            c.signal();
        }).start();
    }
}
